package start.demo01.reflect;


import start.demo01.inherit.Son;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class PrivateTest {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
        Class<Son> cla_son=Son.class;
        Constructor constructors=cla_son.getConstructor();
        Object son=constructors.newInstance();
        //Field field=cla_son.getDeclaredField("ss");
        //field.setAccessible(true);//强制访问私有变量
        //System.out.println("fieldName:  "+field.getName()+"  fieldType:  "+field.getType()+"   fieldValue:  "+field.get(son));
        Method[] methods=cla_son.getDeclaredMethods();
        System.out.println(methods.length);
        Method method=cla_son.getDeclaredMethod("getSs");
        method.invoke(son);
//        for(Method method:methods){
//            System.out.println(" 1"+method.getName());
//        }
    }
}
